<script type="text/javascript" src="/agency/ezbbs/js/swfobject.js"></script>
<script type="text/javascript" src="/agency/ezbbs/js/ezucc.js"></script>

<script for="EzUCCCtrl" type="text/javascript" event="UploadCompleted(msg)" >
// 업로드 이벤트 완료시 처리
//window.alert(msg);

document.getElementById('ucc_name').value = msg;
// 섬네일 이미지 이름 생성 - 파일이름 뒤에 _THUBM_0~5.jpg
var FileName = getFileName(msg);
//window.alert(getFileName(msg));

document.getElementById('ucc_thumbnail').value = FileName + "_Thumb_0.jpg";
document.getElementById('thumb1').src = "/agency/ezbbs/data/ucc/" + FileName + "_Thumb_0.jpg";
document.getElementById('ucc_thumbnail1').value = FileName + "_Thumb_1.jpg";
document.getElementById('thumb2').src = "/agency/ezbbs/data/ucc/" + FileName + "_Thumb_1.jpg";
document.getElementById('ucc_thumbnail2').value = FileName + "_Thumb_2.jpg";
document.getElementById('thumb3').src = "/agency/ezbbs/data/ucc/" + FileName + "_Thumb_2.jpg";
document.getElementById('ucc_thumbnail3').value = FileName + "_Thumb_3.jpg";
document.getElementById('ucc_thumbnail4').value = FileName + "_Thumb_4.jpg";
document.getElementById('ucc_thumbnail5').value = FileName + "_Thumb_5.jpg";
document.getElementById('thumb4').src = "/agency/ezbbs/data/ucc/" + FileName + "_Thumb_3.jpg";
document.getElementById('ucc_flag').value = "ok";
document.getElementById('upload_done_img').src = '/icon/notification_done.gif';
document.getElementById('upload_done_img').width = 16;
document.getElementById('upload_done_img').height = 16;


document.getElementById('preview').style.display = "block";
document.getElementById('thumbsel').style.display = "block";
var flashvars = {
	flvfile:"/agency/ezbbs/data/ucc/" + msg ,
	mainimage:"/agency/ezbbs/data/ucc/"+ FileName +  "_Thumb_0.jpg"
	};
var params = {
	allowfullscreen:"true",
	allowscriptaccess:"always"
	};
var attributes = {
	id:"flvplayer",
	name:"flvplayer"
	};
swfobject.embedSWF("/agency/ezplayer/ezPlayer.swf", "container", "320", "240", "9.0.0", "expressInstall.swf", flashvars , params  ,attributes);

</script>


<script type="text/javascript" >
//<![CDATA[
$(document).ready(function() {
	document.forms["board_insert_form"].elements["eb_subject"].focus();
});

function goto_submit()
{
	<?php if ($_set['artcat_flag']) { ?>
		var tmp = document.board_insert_form.eb_ebcfacid.value;
		if(tmp !='')
		{
			if($("#board_insert_form").valid()) document.board_insert_form.submit();
			else return false;
		}
		else alert("분류를 선택해주세요");

	<?php } else { ?>
		if($("#board_insert_form").valid()) document.board_insert_form.submit();
		else return false;
	<?php } ?>
}





function getFileExtension(filepath)
{
	var lastIndex = -1;
	lastIndex = filepath.lastIndexOf('.');
	var extension = "";

	if(lastIndex != -1)
	{
		extension = filepath.substring(lastIndex=1,filepath.len);
	} else {
		extension = "";
	}

	return extension;
}

function getFileName(filepath)
{
	var lastIndex = -1;
	lastIndex = filepath.lastIndexOf('.');
	var filename = "";

	if(lastIndex != -1)
	{
		filename = filepath.substring(0,lastIndex);
	}
	else
	{
		extension = "";
	}

	return filename;
}

// 무비 업로드 창띄우기
function movie_upload()
{
	// 무비 업로드 창띄우기
	document.EzUCCCtrl.ShowMainDialog();
}


//]]>
</script>

<script type="text/javascript">
//<![CDATA[
function goto_submit()
{
	//1. 제목 체크
	var title = $.trim($("input[name=eb_subject]").val());
	if(title.length < 1)
	{
		alert("제목을 입력하세요.");
		$("input[name=eb_subject]").val("");
		$("input[name=eb_subject]").focus();
		return false;
	}

	//2. 작성인 체크
	var name = $.trim($("input[name=eb_name]").val());
	if(name.length < 1)
	{
		alert("작성인을 입력하세요.");
		$("input[name=eb_name]").val("");
		$("input[name=eb_name]").focus();
		return false;
	}

	//3. 동영상 체크
	var ucc = $.trim($("input[name=ucc_flag]").val());
	if(ucc.length < 1)
	{
		alert("동영상을 입력하세요.");
		$("input[name=ucc_flag]").val("");
		$("input[name=ucc_flag]").focus();
		return false;
	}


	//4. 내용 체크
	var txt = $.trim($("textarea[name=eb_txt]").val());
	if(txt.length < 1)
	{
		alert("내용을 입력하세요.");
		$("textarea[name=eb_txt]").val("");
		$("textarea[name=eb_txt]").focus();
		return false;
	}

	return true;
}

function go_list()
{
	document.location.href = "<?=$_SERVER['PHP_SELF']?>?mid=<?=$mid?>";
}
//]]>
</script>
<style>
#thumbsel ul li 
{
	padding:10px;
	float:left;
}
</style>

<div class="lay_board">
	<form name="board_insert_form1" id="board_insert_form" method='post' action="<?=$EzbbsManager->get_url_root()?>/index.php" target="form_receiver" enctype="multipart/form-data" onsubmit="return goto_submit();">
	<table class="board_write" border="1" cellspacing="0" cellpadding="0">
		<caption>
			글쓰기페이지
		</caption>
		<tr>
		<th scope="row">
			<label for="title">제목</label>
		</th>
			<td>
				<input name="eb_subject" id="title" class="write_form01" type="text" value="" title="제목을 입력해주세요" />
			</td>
		</tr>
		<tr>
		<th scope="row">
			<label for="name">작성자</label>
		</th>
			<td>
				<input name="eb_name" id="name" class="write_form02" type="text" value="" title="작성자를 입력해주세요" />
			</td>
		</tr>
		<tr>
			<th scope="row">
				<label for="email">이메일</label>
			</th>
			<td>
				<input name="eb_eml" id="email" class="write_form01" type="text" value="" title="이메일을 입력해주세요" />
			</td>
		</tr>
		<?php if ($_set['file_num']) { ?>
		<tr>
			<th scope="row">첨부파일</th>
			<td>
				<?php for ($i=0, $size=$_set['file_num']; $i<$size; $i++) { ?>
				<input name="upload_file_<?=$i?>" class="write_form01" type="file" value="" title="첨부파일<?=$i?>을 입력하세요." />
				<?php } ?>
			</td>
		</tr>
		<?php } ?>
		<tr>
			<th scope="row">
				<label for="eb_movie_button">동영상</label>
			</th>
			<td>
				<input type="button" name="eb_movie_button" id="eb_movie_button" class="ezbbs_default" value="동영상업로드" onclick="javascript:movie_upload()" /><input type='hidden' id='ucc_name' name='ucc_name' value="" /><input type='hidden' id='ucc_thumbnail' name='ucc_thumbnail' value="" /><input type='hidden' id='ucc_thumbnail1' name='ucc_thumbnail1' value="" /><input type='hidden' id='ucc_thumbnail2' name='ucc_thumbnail2' value="" /><input type='hidden' id='ucc_thumbnail3' name='ucc_thumbnail3' value="" /><input type='hidden' id='ucc_thumbnail4' name='ucc_thumbnail4' value="" /><input type='hidden' id='ucc_thumbnail5' name='ucc_thumbnail5' value="" /><input type='hidden' id='ucc_size' name='ucc_size' value=""/><input type="hidden" id='ucc_width' name="ucc_width" value="" /><input type="hidden" id='ucc_height' name="ucc_height" value="" /><input type="hidden" id='ucc_path' name="ucc_path" value="/agency/ezbbs/ucc" /><input type="hidden" id='ucc_flag' name="ucc_flag" value="" /> &nbsp;<img src='' id='upload_done_img' name="upload_done_img" width="0" height="0" style="display:none" />

				<div id="preview" style="display:none"><div id="container"></div>
</div>
				<div id="thumbsel" style="display:none" >
				<ul>
				<li><img id="thumb1" name="thumb1" width="120" height="80" border="0" src="" /><br/>
				<label for="ucc_selthumb_1">1번 이미지</label>
				<input type="radio" id="ucc_selthumb_1" name="ucc_selthumb" value="0" checked = "checked" /></li>
				<li><img id="thumb2" name="thumb2" width="120" height="80" border="0" src="" /><br/>
				<label for="ucc_selthumb_2">2번 이미지</label>
				<input type="radio" id="ucc_selthumb_2" name="ucc_selthumb" value="1" /></li>
				<li><img id="thumb3" name="thumb3" width="120" height="80" border="0" src=""/><br/>
				<label for="ucc_selthumb_3">3번 이미지</label>
				<input type="radio" id="ucc_selthumb_3" name="ucc_selthumb" value="2" /></li>
				<li><img id="thumb4" name="thumb4" width="120" height="80" border="0" src="" /><br/>
				<label for="ucc_selthumb_4">4번 이미지</label>
				<input type="radio" id="ucc_selthumb_4" name="ucc_selthumb" value="3" /></li>
				<li>
				</li>
				</ul>
				</div>
			</td>
		</tr>
		<tr>
			<th scope="row">
				<label for="nere_txt">내용</label>
			</th>
			<td class="textarea_text">
				<p>
					<label for="html_flag" class="cla_label_left">HTML적용</label>
					<input type='checkbox' name='eb_html_flag' id='html_flag' value='1'  />
					<label for="br_flag" class="cla_label_left">자동개행</label>
					<input type='checkbox' name='eb_br_flag' id='br_flag' value='1'  checked='checked' />
				</p>
				<textarea name="eb_txt" id="nere_txt" cols="91" rows="15" title="내용을 입력해주세요" class="required"></textarea>
			</td>
		</tr>
	</table>


	<div class="board_detail_btn">
		<ul class="btn01">
			<li>
				<span><input type="image" src="/agency/images/board/confirm_btn.gif" alt="확인" /></span>
				<span><a href="/" onclick="history.back(); return false;"><img src="/agency/images/board/cancel_btn.gif" alt="취소" /></a></span>
			</li>
		</ul>
	</div>


	<input type="hidden" name="job" value="insert" />
	<input type="hidden" name="subjob" value="ok" />
	<input type="hidden" name="eb_seq" value="<?=$eb_seq?>" />
	<?php foreach ($paras as $k => $v) { ?><input type="hidden" name="<?=$k?>" value="<?=$v?>" /><?php } ?>
	</form>

</div>






<script type="text/javascript" >
//<![CDATA[
insert_control()

//]]>
</script>